#define _CRT_SECURE_NO_WARNINGS 1


struct ListNode* reverseList(struct ListNode* head) {
    struct ListNode* pcur = head;
    struct ListNode* pnext = NULL;

    if (pcur == NULL)
        return NULL;
    if (pcur->next == NULL)
        return head;
    pcur = pcur->next;
    pnext = pcur->next;
    head->next = NULL;
    while (pcur)
    {
        pcur->next = head;
        head = pcur;
        pcur = pnext;
        if (pnext != NULL)
            pnext = pnext->next;
    }
    return head;
}